import React, { PureComponent } from 'react'
import {
  BarChart, Bar, Cell, XAxis, YAxis, CartesianGrid, Tooltip, Legend,
} from 'recharts'

export default class Example extends PureComponent {
  static jsfiddleUrl = 'https://jsfiddle.net/alidingling/30763kr7/'

  render() {
    const { data } = this.props
    return (
      <div>
        <BarChart
          width={350}
          height={300}
          data={data}
          style={{
            textAlign: 'center',
            display: 'inline-block',
          }}
          margin={{
            top: 5,
            right: 30,
            left: 20,
            bottom: 5,
          }}
        >
          <CartesianGrid strokeDasharray="3 3" />
          <XAxis dataKey="name" />
          <YAxis />
          <Tooltip />
          <Legend />
          <Bar dataKey="数量" fill="#8884d8" />
        </BarChart>
      </div>
    )
  }
}
